<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<script type="text/javascript" src="/${initParam.rootPath }/se/js/HuskyEZCreator.js" charset="UTF-8"></script>

<b>${requestScope.reviewsboard.no }번 글 수정</b>
<form action="/${initParam.rootPath }/reviewsboard/updatePost.do" method="post" enctype="multipart/form-data" onsubmit="return writeCheck(this);">
<input type="hidden" name="no" value="${requestScope.reviewsboard.no }">
<input type="hidden" name="viewcount" value="${requestScope.reviewsboard.viewcount }">
<input type="hidden" name="page" value="${param.page }">
	<table style="width: 830px;">
		<tr>
			<td>제목</td>
			<td><input type="text" name="title" id="title" maxlength="200" size="50" value="${requestScope.reviewsboard.title }"></td>
		</tr>
		<tr>
			<td>작성자</td>
			<td><input type="text" name="writer" id="writer" value="${sessionScope.login_info.id }" readonly="readonly"></td>
		</tr>
		<tr>
			<td colspan="2">
			<textarea rows="20" cols="110" name="content" id="content">${requestScope.reviewsboard.content }</textarea>
		</tr>
		<tr>
			<td colspan="2" align="center">
			<input type="submit" value="수정">
			<input type="reset" value="초기화">
			</td>
		</tr>
	</table>
</form>

<script type="text/javascript">
var oEditors = [];

nhn.husky.EZCreator.createInIFrame({
	oAppRef: oEditors,
	elPlaceHolder: document.getElementById("content"), 
	sSkinURI: "/${initParam.rootPath }/se/SmartEditor2Skin.html", 
	fOnAppLoad: function(){
		//var title = localStorage.getItem("title");
		//var writer = localStorage.getItem("writer");
		var content = localStorage.getItem("content");
		//document.getElementById("title").value = title;
		//document.getElementById("writer").value = writer;
		oEditors.getById["content"].exec("PASTE_HTML", [content]);
	}, 
	fCreator: "createSEditor2" 
});

function writeCheck(form) {

	if (!form.title.value) {
		alert("제목을 입력하세요.");
		form.title.focus();
		return false;
	}

	if (!form.writer.value) {
		alert("작성자를 입력하세요.");
		form.writer.focus();
		return false;
	}

	oEditors.getById["content"].exec("UPDATE_CONTENTS_FIELD", []);

	var ch = document.getElementById("content").value;
	if (!ch || ch == '<p>&nbsp;</p>') {
		alert("내용을 입력하세요.");
		oEditors.getById["content"].exec("FOCUS", []);
		return false;
	} else {
		try {
			//elClickedObj.form.submit();
			document.boardForm.submit();
		} catch (e) {}
	}
	

};

var pasteHTML = function(filename){
	var sHTML = '<img src="/${initParam.rootPath }/upload/'+filename+'">'; //사진 저장 경로
	oEditors.getById["content"].exec("PASTE_HTML", [sHTML]);
};
</script>

























